<template>
    <div >
      <zh-form ref="formRef" :md="12" :lg="12" :xl="12"  :model="classInfo" :labelWidth="120">
        <zh-form-input prop="parentCode" label="父类编码"  v-model="classInfo.parentCode"
                       disabled></zh-form-input>
        <zh-form-input prop="parentClassTitle" label="父级分类"  v-model="classInfo.parentClassTitle"
                       disabled></zh-form-input>
        <zh-form-input prop="fileClassCode" label="分类编码"  v-model="classInfo.fileClassCode"
                       disabled></zh-form-input>
        <zh-form-input prop="classTitle" label="分类标题"  v-model="classInfo.classTitle"
                       :disabled="props.displayFlag"></zh-form-input>
        <zh-form-input prop="fileEnvID" label="文件环境id"  v-model="classInfo.fileEnvID"
                       :disabled="props.displayFlag"></zh-form-input>
        <zh-form-select
            :disabled="props.displayFlag"
            prop="status"
            label="有效状态"
            :options="state.dictData.status"
            v-model="classInfo.status"
        ></zh-form-select>
        <zh-form-input prop="archivesClassCode" label="档案分类编号"  v-model="classInfo.archivesClassCode"
                       :disabled="props.displayFlag"></zh-form-input>
        <zh-form-select
            :disabled="props.displayFlag"
            prop="fielderShow"
            label="是否需要归档"
            :options="state.fielderShowDict"
            v-model="classInfo.fielderShow"
        ></zh-form-select>
        <zh-form-input prop="fileClassPath" label="文件存放路径"  v-model="classInfo.fileClassPath"
                       :disabled="props.displayFlag"></zh-form-input>
        <zh-form-select
            :disabled="props.displayFlag"
            prop="encryptionFlag"
            label="是否需要加密"
            :options="state.dictData.flag"
            v-model="classInfo.encryptionFlag"
        ></zh-form-select>
        <zh-form-input type="number" prop="maxSize" label="文件大小限制(B)"  v-model="classInfo.maxSize"
                       :disabled="props.displayFlag"></zh-form-input>
        <zh-form-input  prop="fileType" label="文件类型限制"  v-model="classInfo.fileType"
                       :disabled="props.displayFlag"></zh-form-input>
        <zh-form-input type="number" prop="expireTime" label="访问过期时间(S)"  v-model="classInfo.expireTime"
                        :disabled="props.displayFlag"></zh-form-input>
        <zh-form-input  prop="classParam1" label="预留字段1"  v-model="classInfo.classParam1"
                       :disabled="props.displayFlag"></zh-form-input>
        <zh-form-input  prop="classParam2" label="预留字段2"  v-model="classInfo.classParam2"
                        :disabled="props.displayFlag"></zh-form-input>
        <zh-form-input type="textarea"  prop="remarks" label="备注"  v-model="classInfo.remarks"
                        :disabled="props.displayFlag"></zh-form-input>
        <zh-form-select
            :disabled="props.displayFlag"
            prop="secrecyLevel"
            label="保密级别"
            :options="state.secrecyLevelDict"
            v-model="classInfo.secrecyLevel"
        ></zh-form-select>

      </zh-form>
    </div>
</template>

<script lang="ts" setup name="fileClassInfo">
import {FormInstance} from "element-plus";

// ------------------变量区------------------------------
const props = defineProps({
  scrollHeight: {
    type: String,
    default: ''
  },
  displayFlag: {
    type: Boolean,
    default:false
  },
});
const formRef = ref<FormInstance>();
const classInfo = ref<any>({
});

const state = reactive({
  dictData:[],
  fielderShowDict:[
    {
      dictKey:'0',
      dictValue:'不需要'
    },
    {
      dictKey:'1',
      dictValue:'需要'
    },
  ],
  secrecyLevelDict:[
    {
      dictKey:'1',
      dictValue:'一级'
    },
    {
      dictKey:'2',
      dictValue:'二级'
    },
    {
      dictKey:'3',
      dictValue:'三级'
    },
  ]
});

//------------------初始化------------------------------
const params = {
  dictFields: 'status,flag',
};
$api.common.getBatchDict.post(params).then((res) => {
  state.dictData = res.result;
});




//--------------------------定义调用方法--------------------------------------------------
function setInitData(info) {
  formRef.value?.resetFields();
  if (info) {
    if(!info.fileClassCode){
      classInfo.value.parentCode=info.parentCode;
      classInfo.value.parentClassTitle=info.parentClassTitle;
    }else{
      //根据id获取详细信息
      $api.common.fileSend.post('fileClassM0006', {fileClassCode:info.fileClassCode}).then((res) => {
        classInfo.value = res.result;
      }).catch(() => {});
    }
  }
}

//------------设置给父组件调用的数据/方法(组件)-----------
defineExpose({setInitData,classInfo});
</script>
